package com.nthink.indicators.service.hospitalindicators.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nthink.indicators.mapper.hospitalindicators.HumanResourcesMapper;
import com.nthink.indicators.pojo.hospitalindicators.HumanResources;
import com.nthink.indicators.pojo.pie.PieDataModel;
import com.nthink.indicators.service.hospitalindicators.HumanResourcesService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Angus Yu
 * @date 2021-03-30 9:55
 */
@Service
public class HumanResourcesServiceImpl extends ServiceImpl<HumanResourcesMapper, HumanResources> implements HumanResourcesService {


    public HumanResources getData() {
        HumanResources humanResources = new HumanResources();
        humanResources.setNumberOfStaff(baseMapper.getNumberOfStaff());
        humanResources.setEmployeesOnDuty(baseMapper.getEmployeesOnDuty());
        humanResources.setHealthTechnicalPersonnel(baseMapper.getHealthTechnicalPersonnel());
        humanResources.setPharmaceuticalProfessionalsPercent(baseMapper.getPharmaceuticalProfessionals() / (double) humanResources.getEmployeesOnDuty());
        humanResources.setEmergencyDoctorsAndNursesPercent(baseMapper.getEmergencyDoctorsAndNurses() / (double) humanResources.getEmployeesOnDuty());
        humanResources.setDoctorPercent(baseMapper.getDoctor() / (double) humanResources.getEmployeesOnDuty());
        humanResources.setMultipleDepartments(baseMapper.getMultipleDepartments());
        humanResources.setPharmaceuticalProfessionals(baseMapper.getPharmaceuticalProfessionals());
        return humanResources;
    }

    public List<PieDataModel> getHumanResources() {
        List<PieDataModel> dataModelList = new ArrayList<>();

        int employeesOnDuty = baseMapper.getEmployeesOnDuty();
        dataModelList.add(new PieDataModel("employeesOnDuty", baseMapper.getEmployeesOnDuty(), "在岗职工数（全院员工总数）"));
        dataModelList.add(new PieDataModel("healthTechnicalPersonnel", baseMapper.getHealthTechnicalPersonnel(), "卫生技术人员数"));
        dataModelList.add(new PieDataModel("healthTechnicalPersonnel", baseMapper.getPharmaceuticalProfessionals(), "药学专业技术人员"));

        return dataModelList;
    }

    @Override
    public List<PieDataModel> getHumanResourcesPie() {
        return baseMapper.getHumanResourcesPie();
    }

    /**
     * 卫生技术人员职称构成比
     * @return
     */
    @Override
    public List<PieDataModel> getPie1() {
        return baseMapper.getPie1();
    }
    /**
     * 麻醉人员职称构成比
     * @return
     */
    @Override
    public List<PieDataModel> getPie2() {
        return baseMapper.getPie2();
    }
    /**
     * 药学专业技术人员构成比
     * @return
     */
    @Override
    public List<PieDataModel> getPie3() {
        return baseMapper.getPie3();
    }

}
